package org.makabaka.wfwwb.service.Impl;

import org.makabaka.wfwwb.mapper.*;
import org.makabaka.wfwwb.service.DeleteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class DeleteServiceImpl implements DeleteService {

    @Autowired
    private TeamMapper teamMapper;

    @Autowired
    private TeamMemberMapper teamMemberMapper;

    @Autowired
    private AProblemMapper aProblemMapper;

    @Autowired
    private ProblemSelectionMapper problemSelectionMapper;

    @Autowired
    private InstructorMapper instructorMapper;

    @Autowired
    private JudgeMapper judgeMapper;

    @Autowired
    private AScoreMapper aScoreMapper;

    @Autowired
    private BScoreMapper bScoreMapper;

    @Override
    public void deleteAll() throws Exception {
        // 删除所有表的数据，注意顺序以避免外键约束问题

        bScoreMapper.delete(null); // 删除 B 类评分表的数据
        aScoreMapper.delete(null); // 删除 A 类评分表的数据
        judgeMapper.delete(null); // 删除裁判表的数据
        instructorMapper.delete(null); // 删除指导老师表的数据
        problemSelectionMapper.delete(null); // 删除团队选题表的数据
        aProblemMapper.delete(null); // 删除 A 类题目表的数据
        teamMemberMapper.delete(null); // 删除团队成员表的数据
        teamMapper.delete(null); // 最后删除团队表的数据

    }
}
